package com.itao.controller;

import lombok.AllArgsConstructor;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Description
 * @Author sjt
 * @CreateTime 2023/03/13 17:29
 */

@RestController
@AllArgsConstructor
public class LoadBalancerController {
    private LoadBalancerClient client;
    private RestTemplate restTemplate;


    @GetMapping("/order")
    public String order() {
        return restTemplate.getForObject("http://order-service/order", String.class);
    }

    @GetMapping("/nacos")
    public String nacos() {
        return restTemplate.getForObject("http://nacos-server/nacos", String.class);
    }
}
